{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "from ocr import get_ocr\n",
    "from pdf2image import convert_from_path\n",
    "ocr = get_ocr()\n",
    "tmp_im  = convert_from_path('../data/competition_data/pdf/03c625c108ac0137f413dfd4136adb55c74b3805.PDF', dpi=500, first_page=4, last_page=4)\n",
    "# header_area = (0, 0, tmp_im[0].width, 700)\n",
    "        # 使用PIL的crop函数裁剪出页眉部分的图像\n",
    "# header_image = tmp_im[0].crop(header_area)\n",
    "result, _ = ocr(tmp_im[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "安徽黄山胶囊股份有限公司\n",
      "招股意向书\n",
      "发行人声明\n",
      "发行人及全体董事、监事、高级管理人员承诺招股意向书及其摘要不存在\n",
      "虚假记载、误导性陈述或重大遗漏，并对其真实性、准确性、完整性承担个别\n",
      "和连带的法律责任。\n",
      "公司负责人和主管会计工作的负责人、会计机构负责人保证招股意向书及\n",
      "其摘要中财务会计资料真实、完整。\n",
      "保荐人承诺因其为发行人首次公开发行股票制作、出具的文件有虚假记载、\n",
      "误导性陈述或者重大遗漏，给投资者造成损失的，将先行赔偿投资者损失。\n",
      "中国证监会、其他政府部门对本次发行所做的任何决定或意见，均不表明\n",
      "其对发行人股票的价值或投资者的投资收益作出实质性判断或保证。任何与之\n",
      "相反的声明均属虚假不实陈述。\n",
      "根据\n",
      "《证券法》\n",
      "的规定，股票依法发行后，发行人经营与收益的变化，由\n",
      "发行人自行负责，由此变化引致的投资风险，日\n",
      "由投资者自行负责。\n",
      "投资者若对本招股意向书及其摘要存在任何疑问，应咨询自己的股票经纪\n",
      "人、律师、会计师或其他专业顾问。\n",
      "1-1-4\n",
      "\n"
     ]
    }
   ],
   "source": [
    "resp = ''\n",
    "if result:\n",
    "    ocr_result = [line[1] for line in result]\n",
    "    for res in ocr_result:\n",
    "        resp+=res+'\\n'\n",
    "    # resp += \" \".join(ocr_result)\n",
    "print(resp)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
